<template>
  <div>
    <el-form>
      <el-form-item label="考试标题："> {{info.name}} </el-form-item>
      <el-form-item label="出题人：">{{info.username}} </el-form-item>
      <el-form-item label="考试时间："> {{info.time}} 分钟</el-form-item>
      <el-form-item label="考试说明：">
        点击【开始考试】即可开始考试,
        <span class="bold"> 考试时间到会自动提交试卷!!! </span>
      </el-form-item>
      <el-form-item>
        <el-button @click='startExec'>开始考试</el-button>
        <el-button @click='$router.back()'>返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getOnePaper } from "@/api/paper";
export default {
  data() {
    return {
        info: {
            name: '',
            username: '',
            time: '0',
        },
        paperId: ''
    };
  },
  methods: {
      startExec() {
          this.$router.push({name: 'examination', query: {paperId: this.paperId}})
      }
  },
  async created() {
    const { paperId } = this.$route.query;
    const res = await getOnePaper(paperId);
    this.paperId = paperId
    console.log(res)
    if (res.code === 1) {
        this.info = res.data[0]
    } else {
      error(res.msg);
    }
  },
};
</script>

<style></style>
